﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'P_ExistsBasicReference')
	BEGIN
		DROP  Procedure  [esf_sso].P_ExistsBasicReference
	END

GO

CREATE Procedure [esf_sso].P_ExistsBasicReference
	@pID						BIGINT = NULL
	,@pCode						VARCHAR (100) = NULL
	,@pBasicReferenceTypeID		INT	= NULL
AS

	SELECT TOP 1 1 FROM [esf_sso].VBasicReference 
	WHERE 
		(@pCode IS NULL OR Code = @pCode)
		AND (@pID IS NULL OR Name = @pID)
		AND BasicReferenceTypeID = @pBasicReferenceTypeID

GO